package secret

import (
	"mariadb-operator/pkg/apis/finupgroup/v1alpha1"
	"mariadb-operator/pkg/constants"
	"mariadb-operator/pkg/tools/uuid"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func New(cluster *v1alpha1.MariaDBCluster) *corev1.Secret {
	return &corev1.Secret{
		TypeMeta: metav1.TypeMeta{
			APIVersion: "v1",
			Kind:       "Secret",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      constants.DefaultClusterSecretName,
			Namespace: cluster.Namespace,
		},
		Data: map[string][]byte{
			constants.SecretRootPasswordKey: []byte(uuid.UU()),
			constants.SecretUserKey:         []byte(cluster.Spec.DatabaseUser),
			constants.SecretPasswordKey:     []byte(cluster.Spec.DatabasePassword),
			constants.SecretDatabaseNameKey: []byte(cluster.Spec.DatabaseName),
		},
	}
}
